home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5167 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: thor.tu.hac.com!collins
  2. From: collins@thor.tu.hac.com (Ron Collins)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Can main() function be called?
  5. Date: 7 Feb 1996 23:45:38 GMT
  6. Organization: Advanced Depot Systems
  7. Message-ID: <4fbdj2$dmb@hacgate2.hac.com>
  8. References: <823183263.118@fountain.demon.co.uk> <4f1mv0$2fd@cloner4.netcom.com> <4f6n77$e53@library.erc.clarkson.edu>
  9. NNTP-Posting-Host: thor.tu.hac.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Mountain (jimbo) (koglerje@craft.camp.clarkson.edu) wrote:
  13. : Mike Rosenblyum (rozen@ix.netcom.com) wrote:
  14. : : I think that it cannot be done, I see no reasonalbe way how main()
  15. : : could be called more than once.
  16.  
  17.  
  18. : :    What is your thoughts on this?
  19.  
  20.  
  21. : Sure you can call main() again, well kindof,  just uses setjmp()
  22. : and longjmp() just put a setjump() call inside main() like:
  23.  
  24. : int main()
  25. : {
  26. :   setjmp(jmp_buf hi);
  27. :   ..
  28. : }
  29.  
  30. : then when you want to "run main()" again, just call longjmp(jmp_buff hi, int i);
  31. : you will have to look up the specifics but this is standard across the platforms. the real question is WHY would you want to do this??????
  32.  
  33. : hope i was of some assistance.
  34. : jimbo
  35. : koglerje@wckn.dorm
  36.  
  37.  
  38. "main()" is a function like any other function. The only thing special about
  39. it is that the name "main" is called by the C startup code.  But the
  40. startup code only calls it once (at the start of the program, obviously).
  41. You are free to call "main()" as often as you like.
  42.  
  43.             -- collins --
  44.